package com.pocketsweet.utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class ShareReferanceUtils {
	// private static ShareReferanceUtils _instance;
	private Context mContext;
	private SharedPreferences mSetting;
	private Editor mEditor;

	public ShareReferanceUtils(Context context, String fileName) {
		mContext = context;
		mSetting = mContext.getSharedPreferences(fileName,
				Activity.MODE_PRIVATE);
		mEditor = mSetting.edit();
	}

	public void setIntValue(String name, int value) {
		mEditor.putInt(name, value).commit();
	}

	public int getIntDefaultNagative1(String name) {
		return mSetting.getInt(name, -1);
	}

	public int getIntValue(String name,int defaultValue) {
		return mSetting.getInt(name, defaultValue);
	}

	public boolean getBooleanValue(String key, boolean defaultValue) {
		return mSetting.getBoolean(key, defaultValue);
	}

	public void setBooleanValue(String key, boolean value) {
		mEditor.putBoolean(key, value).commit();
	}

	public void removeAll() {
		mEditor.clear().commit();
	}
	
	public void remove(String key) {
		mEditor.remove(key).commit();
	}

	public void setStringValue(String key, String value) {
		mEditor.putString(key, value).commit();
	}

	public String getStringValue(String key, String defaultValue) {
		return mSetting.getString(key, defaultValue);
	}
}
